package com.cocostudio.erpapp.adapter;

import java.util.ArrayList;

import com.cocostudio.erpapp.R;
import com.cocostudio.erpapp.vo.ErpDeptment;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public  class DeptmentAdapter extends BaseAdapter {
    private Context mContext;
    private ArrayList<ErpDeptment> mData;
    private LayoutInflater mLayoutInflater;

    public DeptmentAdapter(Context context, ArrayList<ErpDeptment> data) {
        mContext = context;
        mData = data;
        mLayoutInflater = LayoutInflater.from(context);
    }
    @Override
    public int getCount() {
        return mData == null ? 0 : mData.size();
    }
    @Override
    public ErpDeptment getItem(int position) {
        return mData == null ? null : mData.get(position);
    }
    
    @Override
    public long getItemId(int position) {
        return position;
    }
    
   
    @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            LayoutInflater _LayoutInflater=LayoutInflater.from(mContext);
            //convertView=_LayoutInflater.inflate(android.R.layout.simple_dropdown_item_1line, null);
            convertView=_LayoutInflater.inflate(R.layout.deptment_list_item, null);

            
            if(convertView!=null)
            {
               // TextView _TextView1=(TextView)convertView.findViewById(android.R.id.text1);
                TextView _TextView1=(TextView)convertView.findViewById(R.id.app_deptment_list_item_label);

                _TextView1.setText(mData.get(position).getName());
                
            }
            return convertView;
        }
}
